﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using HSE.Events;
using DIST.LR.ZHJG.Events;
using PetroMentor.Service;
using System.Collections.ObjectModel;
using HSE.Common;
using System.Windows.Threading;
using PetroMentor.Service.Entities;

namespace HSE
{
    public partial class Aqxs : UserControl
    {
        AqxsViewModel viewmodel;
        Storyboard sbshow, sbhidden;
        public Aqxs()
        {
            InitializeComponent();
            sbshow = this.Resources["showAttachmentBorder"] as Storyboard;
            sbhidden = this.Resources["hiddenAttachmentBorder"] as Storyboard;
            viewmodel = new AqxsViewModel();
            viewmodel.AttachmentButtonClickEvent += new AqxsViewModel.AttachmentButtonClickHandler(viewmodel_AttachmentButtonClickEvent);
            EventAggregatorRepository.EventAggregator.GetEvent<QueryEvent<T_WHYL_AQXS>>().Subscribe(QueryHandler);
            this.Loaded += new RoutedEventHandler(Aqxs_Loaded);
            gridview.PageChanged += new TelerikGridView.PageChangedHandler(gridview_PageChanged);
        }

        void gridview_PageChanged(int pagenumber)
        {
            viewmodel.Select(pagenumber, 10, "");
        }

      

        void viewmodel_AttachmentButtonClickEvent(T_WHYL_AQXS current)
        {
            sbshow.Begin();

            PictureAttachmentViewModel viewmodel = new PictureAttachmentViewModel();
            ObservableCollection<PhotoInfo> temps = new ObservableCollection<PhotoInfo>();
            temps.Add(new PhotoInfo() { TipInfo = "2013.8.3大牛地ZD023基层队岗前宣誓", Icon = "../Images/whyl/gqxs.jpg" });
            temps.Add(new PhotoInfo() { TipInfo = "2013.7.3中石化新员工宣誓", Icon = "../Images/whyl/xygxs1.jpg" });
            temps.Add(new PhotoInfo() { TipInfo = "2013.2.3鄂北ZD066基层队开钻宣誓", Icon = "../Images/whyl/xygxs1.jpg" });
            viewmodel.Title = "现场情况";
            viewmodel.Photos = temps;
            showAttachment.ShowAttachment(viewmodel);
        }

        public void Aqxs_Loaded(object sender, RoutedEventArgs e)
        {
            viewmodel.Select(1, 10, "");
        }

        public void QueryHandler(CommonQueryInfo<T_WHYL_AQXS> info)
        {
            gridview.Init(GridMode.View,viewmodel.Columns);
            gridview.Binding<T_WHYL_AQXS>(info);
        }

        private void Image_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            sbhidden.Begin();
        }

    }
}
